home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_3.zip / PC-2-PC.SRC < prev    next >
Text File  |  1992-11-30  |  53KB  |  2,114 lines

  1. S29 = "ATE0Q0V1X1S0=2 S7=30 S9=10^M"    ; Modem init for autoconnect
  2. S19 = "PC-2-PC ver 1.1     "            ; 20 chars long
  3. ;
  4. ; ----- COM-AND Scripted PC-2-PC link
  5. ;    Commenced: 09/20/88 R.McG
  6. ;
  7. ;    Modified:  09/27/91
  8. ;           1.  To correctly transfer filenames with special characters,
  9. ;           such as "!" for both remote and local directories.
  10. ;    ..     2.  Also modified to use ZMODEM for all file transfers.
  11. ;    ..     3.  Also added CONNECT and DISCONNECT CLOG entries in order
  12. ;           that CALOGS will be able to process direct connections too.
  13. ; -----------------------------------------------------------------------
  14. ;    Goals:
  15. ;    o    Must autodetect connection
  16. ;    o    Must dial number on request
  17. ;    o    Must work correctly for modems reporting true CD and
  18. ;        also for direct connects
  19. ;
  20. ;    Functions:
  21. ;    o    Directory list - our current directory
  22. ;    o    Directory list - linked PC directory
  23. ;    o    Change subdirectory - our PC
  24. ;    o    Change subdirectory - linked PC
  25. ;    o    Transfers either way
  26. ; -----------------------------------------------------------------------
  27. ;    Usages:
  28. ;      FLAG(0) -> ON if link established
  29. ;      FLAG(1) -> ON if caller or initiator of connect
  30. ;      FLAG(2) -> Off if we are on 'our' side of the display
  31. ;      FLAG(3) -> On if direct connect
  32. ;
  33. ;      S29 -----> Modem initialization, including autoconnect command
  34. ;      S19 -----> Legend line
  35. ;      S18 -----> Load-time drive:subdirectory (for exit)
  36. ;      S17 -----> Load-time download d:subdir (for exit)
  37. ;
  38. ;      N99 -----> # screen lines
  39. ;      N98 -----> Debugging flag (for one side, two side tests)
  40. ;
  41. ;      N90 -----> Current cursor (1 to N99-5)
  42. ;      N91 -----> # local files selected
  43. ;      N92 -----> # remote files selected
  44. ;
  45. ;      S16 -----> local files selected (13 chars/field)
  46. ;      S15 -----> Remote files selected (13 chars/field)
  47. ;
  48. ;      S12 -----> Used by Change sides for line read/write
  49. ;      S11 -----> Used by various routines for saved file name
  50. ;      S10 -----> Used by various routines for saved ON ESCAPE label
  51. ; -----------------------------------------------------------------------
  52. ;
  53. ;    Initialization
  54. ;
  55. LEGEND S19            ; Set initial legend
  56. SUBDIR S18            ; Read current subdir
  57. DLDIR S17            ; Read current download subdir
  58. SET DLDIR " "                   ; Set download subdir to default
  59. SET FLAG(0) OFF         ; No current link
  60. SET FLAG(1) ON            ; Default - we called/initiated
  61. SET FLAG(2) Off         ; Default - on 'our side' of the display
  62. SET FLAG(3) Off         ; Default - dialed connect
  63. SET CDISP ON            ; Display control chars
  64. SET RDISP OFF            ; Don't display received chars
  65. SET SOFTFLOW OFF        ; Turn off our own flowctl
  66. ;SET HARDFLOW ON        ; Turn on hdwe flowctl
  67. SET ATIME 0            ; Set no alarm time
  68. SET ALARM OFF            ; Set no alarm sound
  69. SET CHAT OFF            ; Set chat off (just in case)
  70. SET XSUI 10            ; Set transer screen update interval
  71. ON ESCAPE GOSUB Exit        ; Escape action
  72. N90 = N91 = N92 = 0        ; Clear # files selected, cursor
  73. S16 = ""
  74. S15 = ""
  75. ;
  76. ;    Make 8n1 for best KERMIT throughput
  77. ;
  78. SET PARITY NONE
  79. SET DATA 8
  80. SET STOP 1
  81. ;
  82. ;    Debugging flag
  83. ;
  84. N98 = 0             ; Debugging if <> zero
  85. ;
  86. ;    Draw the screen, and decide if we're linked
  87. ;
  88. GOSUB InitScreen
  89. GOSUB BuildLocDir        ; Build our directory list
  90. IF ZERO N98            ; Test for debugging
  91.    GOSUB LinkTest        ; Not - make the link
  92. ELSE
  93.    FOPENI "PC2PC.LOC" TEXT      ; Open the file
  94.    ENDIF
  95. ;
  96. ; ----- Update the legend, and accept a command
  97. ;
  98. Main:
  99.     LEGEND S19
  100.     LOCATE (N99-3),77    ; Set the cursor
  101.     SOUND 440,100        ; Indicate we're ready
  102.     SET TTHRU OFF
  103. ;
  104. ;    Loop, waiting for a keypress or received commands
  105. ;
  106. Main100:
  107.     IF HITKEY        ; If a keypress pending
  108.        GOTO MAIN200     ; .. go handle it
  109.        ENDIF
  110.     IF RECEIVE        ; If comm port chars pending
  111.        GOTO MAIN300     ; .. go handle it
  112.        ENDIF
  113.     IF ZERO N98 AND NOT CONNECTED
  114.        GOTO Exit
  115.        ENDIF
  116.     GOTO Main100        ; And loop
  117. ;
  118. ;    We have a keypress pending
  119. ;
  120. MAIN200:
  121.     KEYGET S1        ; Read a single key
  122.     SWITCH S1
  123.        CASE "C"             ; Change directory
  124.           GOSUB ChangeOurDir
  125.        ENDCASE
  126.        CASE "E"             ; Exit
  127.           GOTO Exit     ; And exit
  128.        ENDCASE
  129.        CASE "H"             ; Help
  130.           GOSUB Help
  131.        ENDCASE
  132.        CASE "S"             ; Select
  133.           GOSUB Select
  134.        ENDCASE
  135.        CASE "T"             ; Transfer
  136.           GOSUB Transfer
  137.        ENDCASE
  138.        CASE "W"             ; Wildcard
  139.           GOSUB Wildcard    ; Send using wildcards
  140.        ENDCASE
  141.        CASE "4D00"          ; Cursor_Right
  142.           GOSUB Change_Sides
  143.        ENDCASE
  144.        CASE "4B00"          ; Cursor left
  145.           GOSUB Change_Sides
  146.        ENDCASE
  147.        CASE "4900"          ; PgUp
  148.           GOSUB Prev_Page
  149.        ENDCASE
  150.        CASE "5100"          ; PgDn
  151.           GOSUB Next_Page
  152.        ENDCASE
  153.        CASE "4700"          ; Home
  154.           GOSUB Home_Page
  155.        ENDCASE
  156.        CASE "4F00"          ; End
  157.           GOSUB End_Page
  158.        ENDCASE
  159.        CASE "4800"          ; Cursor Up
  160.           GOSUB Cursor_Up
  161.        ENDCASE
  162.        CASE "5000"          ; Cursor down
  163.           GOSUB Cursor_Down
  164.        ENDCASE
  165.        CASE "7100"          ; Alt-F10
  166.           SHELL
  167.        ENDCASE
  168.        DEFAULT
  169.          SOUND 100,100    ; Signal displeasure
  170.        ENDCASE
  171.     ENDSWITCH
  172.     GOTO Main        ; And continue
  173. ;
  174. ;    We have characters pending on the communications line
  175. ;
  176. MAIN300:
  177.     RGET S1 1        ; Read a single character
  178.     SWITCH S1
  179.        CASE "R"             ; Change directory
  180.           RGET S1 80 10    ; Read remainder
  181.           TRANSMIT "+!"     ; Acknowlege
  182.           GOSUB Remote_Chdir
  183.        ENDCASE
  184.        CASE "E"             ; Sender's local changed
  185.           GOTO Exit
  186.        ENDCASE
  187.        CASE "L"             ; Sender's local changed
  188.           RGET S1 80 10    ; Read remainder
  189.           TRANSMIT "+!"     ; Acknowlege
  190.           GOSUB Local_Chdir
  191.        ENDCASE
  192.        CASE "T"             ; Sender wants to transfer
  193.           RGET S1 80 10    ; Read remainder - note no ACK
  194.           GOSUB Rcv_Transfer
  195.        ENDCASE
  196.        CASE "W"             ; Sender's wants to xfer batch
  197.           RGET S1 80 10    ; Read remainder - note no ACK
  198.           GOSUB Rcv_Wildcard
  199.        ENDCASE
  200. ;       CASE "^M"            ; Carriage rtn
  201. ;       ENDCASE        ; Ignore it
  202.        CASE "?"             ; Link request
  203.           TRANSMIT "PC-2-PC!"
  204.           SET FLAG(1) OFF    ; Indicate we're receiving
  205.           GOSUB Exchange    ; Exchange directories
  206.        ENDCASE        ; Ignore it
  207.        DEFAULT        ; Unrecognized
  208.           RFLUSH        ; Clear line
  209.           GOTO Main100    ; And continue w/o beep
  210.        ENDCASE
  211.     ENDSWITCH
  212.     GOTO Main        ; And continue
  213. ;
  214. ; ----- Exit procedure - ESC has been hit
  215. ;    .. Restore screen, close files and delete temps
  216. ;
  217. Exit:
  218.     IF FLAG (0)        ; If linked
  219.        TRANSMIT "E!"        ; Terminate remote too
  220.        SET FLAG(0) OFF
  221.        ENDIF
  222.     TSINCE (9) N9,N8,N7
  223.     S3 = "DISCONNECT: ("&N9&":"&N8&":"&N7&")"
  224.     CLOG S3
  225.     IF CONNECTED and NOT FLAG(3)
  226.        HANGUP        ; Hangup if not direct
  227.        ENDIF
  228.     DO            ; There may be multiple saves outstanding
  229.        RESTORE        ; .. restore all
  230.        UNTIL FAILURE
  231.  
  232.     FCLOSEI         ; CLose files
  233.     FCLOSEO         ; ..
  234.     DELETE "PC2PC.LOC"      ; And delete them too
  235.     DELETE "PC2PC.REM"      ; ..
  236.  
  237.     CHDIR S18        ; Reset current subdir
  238. ; ***    SET HARDFLOW OFF    ; Disable
  239. ;
  240. ; ----- Terminate COM-AND and the script
  241. ;
  242.     SET CDRESPECT ON    ; Skip 'connected' query on exit
  243.     BYE            ; Terminate script AND COM-AND
  244. ;
  245. ; ----- Alternative to above... exit script
  246. ;    .. exchange this paragraph and the above if you want it this way
  247. ;    .. taking off the "***"s
  248. ;
  249. ***    RESET            ; Reset default parameters (bye doesn't care)
  250. ***    EXIT            ; And exit script
  251. ;
  252. ; ----- Subroutine: Clear the current cursor
  253. ;    .. according to the current stting of FLAG(2)
  254. ;
  255. Clear_Cursor:
  256.     IF NOT ZERO N90
  257.        GOSUB Read_Cursor
  258.        IF FLAG(2)        ; IF true we're on remote
  259.           ATSAY N90,41 (default) S12
  260.        ELSE
  261.           ATSAY N90, 2 (default) S12
  262.           ENDIF
  263.        ENDIF
  264.     RETURN
  265. ;
  266. ; ----- Subroutine: Display the current cursor
  267. ;    .. according to the current stting of FLAG(2)
  268. ;
  269. Set_Cursor:
  270.     GOSUB Read_Cursor
  271.     IF NOT ZERO N90
  272.        IF FLAG(2)        ; IF true we're on remote
  273.           IF NOT NULL S12
  274.          ATSAY N90,41 (contrast) S12
  275.           ELSE
  276.          N90 = N90-1
  277.          GOTO Set_Cursor
  278.          ENDIF
  279.        ELSE         ; On own side
  280.           IF NOT NULL S12
  281.          ATSAY N90, 2 (contrast) S12
  282.           ELSE
  283.          N90 = N90-1
  284.          GOTO Se